package actions;

import java.sql.SQLException;
import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.RowSet;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import db.DbException;
import model.SpecializationsModel;
import model.UniversityModel;

public class DegreeEndAction extends Action {

	private static final boolean DEBUG = true;
	//private static final int UNKNOWN = -1;
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws DbException {
	
		// put list of universities into a vector
		RowSet rset = SpecializationsModel.getAllSpecializations();

		Vector<String> specializations = new Vector<String>();
		
		try {
			while (rset.next()) {
				specializations.add(rset.getString("specialization"));
			}
		} catch (SQLException e) {
			System.err.println("SQLException: " + e.getMessage());
		}
		
		request.setAttribute("specializations", specializations);
		
		return mapping.findForward("success");
	}
	
}
